<%@ page language="java" import="java.util.*" pageEncoding="utf8"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="com.taobao.snowsnow.hibernate.service.*"%>
<%@page import="com.taobao.snowsnow.hibernate.service.impl.*"%>
<%@page import="com.taobao.snowsnow.hibernate.pojo.*"%>
<%@page import="com.taobao.snowsnow.util.*"%>
<%@page import="com.taobao.snowsnow.hibernate.temp.*"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/showProductInfo" prefix="cc"%>
<link rel="stylesheet" type="text/css" href="css/trade.css" />
<link rel="stylesheet" type="text/css" href="css/thickbox.css" />
<script type="text/javascript" src="./js/thickbox.js"></script></p>
<link rel="stylesheet" href="./css/themes/base/jquery.ui.all.css">
<script src="./js/jquery-latest.js"></script>
<script src="./js/jquery-ui-1.8.24.custom.min.js"></script>
<link rel="stylesheet" href="./css/demos.css">
<script type="text/javascript">
   $(document).ready(function () {
   		init();
   		$("#express").attr("value", "申通E物流");
    });
</script>
<style type="text/css">
</style>
<%
	response.setCharacterEncoding("utf8");
	String status = request.getParameter("status");
	String url = "http://item.taobao.com/item.htm?id=";
	ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
	ProductCollectService productCollectService = (ProductCollectService) context.getBean("ProductCollectService");
	ExpressService expressService = (ExpressService) context.getBean("ExpressService");
	List<Trade> tradeCollect = (List<Trade>) request.getSession().getAttribute("tradeList");
	List<Express> express = expressService.findAll();
	
	request.setAttribute("tradeCollect", tradeCollect);
	request.setAttribute("express", express);
	//request.getSession().setAttribute("tradeCollect", tradeCollect);
%>

<div id="dialog-searchTrace" title="快递单查询">
</div>

<s:form action="">
	
	<div id="tradeTable">
     	<table class="datalist">
         	<col class="col1" />
         	<col class="col2" />
         	<col class="col3" />
         	<col class="col4" />
         	<col class="col5" />
         	<col class="col6" />
         	<col class="col7" />
         	<col class="col8" />
         	<thead>
             	<tr>
                 	<th scope="col" width="10px">&nbsp;</th>
                    <th scope="col" width="15px">ID</th>
                    <th scope="col" width="80px" style="padding: 0px; margin: 0px;">图片</th>
	                <th scope="col">商品名称</th>
	                <th scope="col" width="100px">商品颜色</th>
	                <th scope="col" width="70px">商品单价</th>                            
	                <th scope="col" width="30px">数量</th>
	                <th scope="col" width="30px">制作方法</th>
	            </tr>
        </thead>
        
        <tbody>
        	<tr>
        		<td colspan="8"> 
        			<c:set var="listLength" >
        				<s:property value="%{#request.tradeCollect.size()}" />
        			</c:set>
        			<input type="checkbox" id="selectAllChecked" />
        			<button onclick="printAllExpressPage();return false;">打印全部快递单</button>
        			<input type='button' id='collapseAllOrder'	onclick='collapseAll("${listLength}", true)' value='折叠全部' />
        			请选择快递公司:   
        			<s:select 
        				name="express.codeName"
        				id="express"
        				list="#request.express"
        				listValue="name"
        				listKey="name"
        				value="2"
        		    />
				</td>
        	</tr>
        </tbody>
        
        <c:set var="c" value="1" />
        <c:forEach var="trade" items="${tradeCollect}">
        	<tbody>
        		<tr class="sep-row" style="background-color:  #00;">
        			<td colspan="8">&nbsp;</td>
        		</tr>
        		<tr>
        			<td colspan="8">	
        				<div id="tradeDetail">
	        				<input type="checkbox" name="tids" value="${trade.tid}" />
	        				 订单编号: ${trade.tid}
			                 成交时间：${trade.createTime}
			                 <b>
			                 	买家ID:
			                 	<c:set var="color" value="black" />
			                 	<c:if test="${trade.descs == 'old customer'}">
			                 		<c:set var="color" value="green" />
			                 	</c:if>
			                 	<font color="${color}">${trade.people.taobaoId }</font>
			                 </b>
			                 总金额: ${trade.totalPrice}
	        			</div>
        			</td>
        		</tr>
        		
        		<tr>
        			<td colspan="8">
        				<input type='button' value='折叠'	id='button_${c}' onclick='expand(${c}, true)' />
        				<button onclick="printExpressPage(${ trade.tid });return false;">打印快递单</button>
        				<button onclick="openUrl(${ trade.tid });return false;">发货</button>
        				<button type='button' onclick='searchLog(${trade.tid});return false;' >查物流</button>
        			</td>
        		</tr>
        		
        		<c:set var="show" value="" />
   				<c:if test="${trade.buyyerMessage == null}">
   					<c:set var="show" value="display:none;" />
   				</c:if>
        		<tr style="${show}" class="buyyerMessage">
        			<td colspan="8">
        				买家留言: <b><font color="#FF0000">${trade.buyyerMessage}</font></b>
        			</td>
        		</tr>
        		
        		<c:set var="show" value="" />
   				<c:if test="${trade.sellerMemo == null}">
   					<c:set var="show" value="display:none;" />
   				</c:if>
        		<tr style="${show}" class="sellerMemo">
        			<td colspan="7">
        				卖家留言: <b><font color="#FF0000">${trade.sellerMemo}</font></b>
        			</td>
        		</tr>
        		
        		<c:forEach var="order" items="${trade.orders}">
        			<tr class="altrow" name="item${c}">
		            	<td>&nbsp;</td>
		                <td>1</td>
		                <td>
		                	<a class="thickbox" title="${order.product.productCollect.name}" href="${order.product.productCollect.picUrl}">
		                		<img src="${order.product.productCollect.picUrl}_sum.jpg" />
		                	</a>
		                </td>
		                <td><a href="${order.product.productCollect.itemUrl}" target="_blank">${order.product.productCollect.name}</a></td>
		                <td>
		                	<b><font color="#FF0000">${order.descs}</font></b>	
		                </td>
		                <td>${order.price}</td>
		                <td>${order.quantity}</td>
		                <td><input type="button" value="点击查看参数" onclick="javascript:showBowParam(${order.product.productCollect.id});return false;" /></td>
		            </tr>
        		
        		</c:forEach>
	            
        	</tbody>
        	<c:set var="c">
				${c + 1}
 			</c:set>
        </c:forEach>
    </table>
</div>
<div>
	一共有<s:property value="#request.tradeCollect.size()" />单
</div>
</s:form>